﻿/* *****************************************************************************
 * @ Encoding: UTF-8
 * @ File Name: naughty_differential_node_exp.cpp
 * @ Author: carl
 * @ Email: naughtygeng@qq.com
 * @ Created Time: 2022-7月-12(星期二) 22:26:24
 * @ All Rights Reserved
 * *****************************************************************************/

#include "naughty_differential_node_exp.hpp"
#include "naughty_differential_node_num.hpp"
#include "naughty_differential_node_mul.hpp"

namespace naughty_differential
{

node_exp::node_exp(std::shared_ptr<node_base> param)
    :
        node_base({param})
{

}

node_exp::node_exp(std::vector<std::shared_ptr<node_base>> params)
    :
        node_base(params)
{

}

std::shared_ptr<node_base> node_exp::differential(std::string variable)
{
    return std::make_shared<node_mul>(std::make_shared<node_exp>(get_parameters()[0]), get_parameters()[0]->differential(variable));
}

enum node_type node_exp::get_node_type()
{
    return node_type_exp;
}

std::string node_exp::serialize()
{
    return {};
}

std::string node_exp::to_string() const
{
    return std::string("exp(") + get_parameters()[0]->to_string() + ")";
}

std::shared_ptr<node_base> node_exp::clone()
{
    return std::make_shared<node_exp>(parameters_clone());
}

double node_exp::get_value(std::map<std::string, double> val_value_map)
{
    std::vector<double> params_value = get_params_value(val_value_map);

    return std::exp(params_value[0]);
}

std::string node_exp::identity_string() const
{
    return std::string("exp(") + get_parameters()[0]->to_string() + ")";
}

}
